package com.jcl.recruit.elasticsearch.resume.dao;

import com.jcl.core.utils.CollectionUtils;
import com.jcl.recruit.elasticsearch.mapper.SearchResumePersInfoMapper;
import com.jcl.recruit.elasticsearch.resume.model.SearchResumePersInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName SearchResumePersInfoDao
 * @Author yyliu
 * @Date 2018/11/17 11:52
 * @Version 1.0
 **/
@Component
public class SearchResumePersInfoDao implements SearchResumePersInfoMapper {

    @Autowired
    SearchResumePersInfoMapper searchResumePersInfoMapper;

    public Map<Integer, SearchResumePersInfo> findEntityMapByResumeIds(List<Integer> resumeIds) {
        Map<Integer, SearchResumePersInfo> dataMap = new HashMap<>();
        List<SearchResumePersInfo> list = searchResumePersInfoMapper.findListByResumeIds(resumeIds);
        if (CollectionUtils.isNotEmpty(list)) {
            for (SearchResumePersInfo entity : list) {
                dataMap.put(entity.getResumeId(), entity);
            }
        }

        return dataMap;
    }

    @Override
    public List<SearchResumePersInfo> findListByResumeIds(List<Integer> resumeIds) {
        return searchResumePersInfoMapper.findListByResumeIds(resumeIds);
    }

    @Override
    public Map<String, Object> findOneMap(Integer resumeId) {
        return searchResumePersInfoMapper.findOneMap(resumeId);
    }

    @Override
    public SearchResumePersInfo findOne(Integer resumeId) {
        return searchResumePersInfoMapper.findOne(resumeId);
    }

    @Override
    public int add(SearchResumePersInfo entity) {
        return searchResumePersInfoMapper.add(entity);
    }

    @Override
    public int batchDeleteByResumeIds(List<Integer> resumeIds) {
        return searchResumePersInfoMapper.batchDeleteByResumeIds(resumeIds);
    }
}
